package com.akkainaction.tool.eventbus;

import akka.actor.*;
import com.akkainaction.tool.eventbus.actor.EventBusActor;
import com.akkainaction.tool.eventbus.actor.EventStreamActor;

public class TestEventStream {

    public static void main(String[] args) {
        ActorSystem system = ActorSystem.create("sys");
        ActorRef eventBusActorRef = system.actorOf(Props.create(EventBusActor.class), "eventBusActor");
        ActorRef actorRef = system.actorOf(Props.create(EventStreamActor.class), "actor");
        //为actorRef订阅了DeadLetter
        system.eventStream().subscribe(actorRef, DeadLetter.class);
        //将eventBusActorRef kill掉
        eventBusActorRef.tell(Kill.getInstance(),ActorRef.noSender());
        //向一个已经死亡的消息发送消息
        eventBusActorRef.tell("hello",ActorRef.noSender());
    }
}
